package tree;

/**
 * @author way
 * @create 2025-02-16 17:22
 */
public class _108_sortedArrayToBST {
    public TreeNode sortedArrayToBST(int[] nums) {
        return deal(nums, 0, nums.length);
    }

    private TreeNode deal(int[] nums, int left, int right) {
        if (left == right) return null;

        int mid = left + (right - left) / 2;
        TreeNode root = new TreeNode(nums[mid]);
        root.left = deal(nums, left, mid);
        root.right = deal(nums, mid + 1, right);
        return root;
    }
}
